import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:oi_ai_tool/controller/home_page_controller.dart';
import 'package:oi_ai_tool/controller/oi_token_controller.dart';
import 'package:oi_ai_tool/util/oi_logger.dart';
import 'package:oi_ai_tool/view/home/home_page.dart';
import 'package:oi_ai_tool/view/setting/oi_setting.dart';
import 'package:oi_ai_tool/view/token/oi_token.dart';

class OiRoute {
  static final pages = [
    OiGetPage(
        name: Routes.Initials,
        page: () => const MyHomePage(
              title: "OI",
            ),
        binding: BindingsBuilder(
          () {
            Get.lazyPut(() => HomePageController());
          },
        )),
    OiGetPage(
      name: Routes.Setting,
      page: () => const OiSetting(),
    ),
    // OiGetPage(
    //   name: Routes.Mine,
    //   page: () => const OiMine(),
    //   fullscreenDialog: true,
    //   transition: Transition.downToUp,
    // ),
    OiGetPage(
        name: Routes.Token,
        page: () => const OiToken(),
        binding: BindingsBuilder(() {
          Get.lazyPut(() => OiTokenController());
        })),
  ];

  static go(String page, {dynamic arguments, int? id}) {
    OiLogger.debug(msg: "go $page");
    Get.toNamed(page, arguments: arguments, id: id);
  }

  static off(String page, {dynamic arguments, int? id}) {
    OiLogger.debug(msg: "off $page");
    Get.offNamedUntil(page, ModalRoute.withName(page),
        arguments: arguments, id: id);
  }

  static back() {
    Get.back();
  }
}

class OiGetPage extends GetPage {
  OiGetPage({
    required super.name,
    required super.page,
    Transition? transition,
    bool? fullscreenDialog,
    super.binding,
  }) : super(
            transition: transition ?? Transition.cupertino,
            fullscreenDialog: fullscreenDialog ?? false);
}

class Routes {
  static const String Initials = "/";
  static const String Setting = "/setting";
  static const String Mine = "/mine";
  static const String More = "/more";
  static const String Add = "/add";
  static const String Token = "/token";
}
